package demo.test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 复制图片方法类123456
 * @author deekeydai
 *
 */
public class CopyImage {

	public static void main(String[] args) {
		File Afile = new File("C:\\Users\\deekeydai\\Desktop\\gittest\\A\\image.jpg");
		File Bfile = new File("C:\\Users\\deekeydai\\Desktop\\gittest\\B");
		if (!Bfile.exists()) {
			Bfile.mkdir();
		}

		try {
			FileInputStream inputStream = new FileInputStream(Afile);
			FileOutputStream outputStream = new FileOutputStream(new File("C:\\Users\\deekeydai\\Desktop\\gittest\\B\\image.jpg"));

			int ch = inputStream.read();
			while (ch != -1) {
				outputStream.write(ch);
				ch = inputStream.read();
			}
			inputStream.close();
			outputStream.close();
			System.out.println("图片复制成功！");
		} catch (FileNotFoundException e) {
			System.out.println("文件不存在123456：" + e.getMessage());
		} catch (IOException e) {
			System.out.println("文件读取错误：" + e.getMessage());
		}

	}

}
